package com.chentongwei.spring.annotation.conditional.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author TongWei.Chen 2018-07-04 11:04:56
 * @Description:
 * @Project spring-annonation
 */
public class WindowsCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        // 获取当前环境信息
        Environment environment = context.getEnvironment();

        String osname = environment.getProperty("os.name");

        if (osname.contains("Windows")) {
            return true;
        }

        return false;
    }
}
